fix(updater): Pass OriginalTag to post-update script on second run#133
fix(updater): Pass OriginalTag to post-update script on second run#133
Conversation
When the updater creates a new PR and runs the update-dependency script a second time, it was not passing the OriginalTag parameter. This caused the script to fail validation since Tag requires OriginalTag to be set. Changes: - Updated action.yml to pass OriginalTag on second script execution - Added unit test for explicit Tag/OriginalTag parameters - Added validation test to ensure Tag fails without OriginalTag All 34 tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
| [string] $GhTitlePattern = '', | ||
| # Specific version - if passed, no discovery is performed and the version is set directly | ||
| [string] $Tag = '', | ||
| # Version that the dependency was on before the update - should be only passed if $Tag is set. Necessary for PostUpdateScript. | ||
| [string] $OriginalTag = '', | ||
| # Optional post-update script to run after successful dependency update | ||
| # The script receives the original and new version as arguments | ||
| [string] $PostUpdateScript = '' |
There was a problem hiding this comment.
Potential bug: The script uses lowercase variables $tag and $originalTag, but the parameters are defined as $Tag and $OriginalTag, leading to incorrect behavior.
-
Description: In the execution path where
TagandOriginalTagare explicitly provided, the script attempts to use lowercase variables$tagand$originalTag. However, these variables are not defined in this scope; the correct, case-sensitive parameters are$Tagand$OriginalTag. Because PowerShell treats undefined variables as empty strings, the call toDependencyConfig 'set-version' $tagwill incorrectly update the dependency file with an empty version. Additionally, the post-update script will be called with empty parameters, causing the dependency update process to fail or produce incorrect results. This bug occurs specifically in the new scenario introduced by the code change. -
Suggested fix: Correct the variable names used in the core functionality to match the case of the defined parameters. Change
$tagto$Tagand$originalTagto$OriginalTagwhere they are used to callDependencyConfigand the post-update script.
severity: 0.85, confidence: 0.98
Did we get this right? 👍 / 👎 to inform future reviews.
| } | ||
|
|
||
| if ("$Tag" -eq '') { | ||
| $OriginalTag | Should -Be '' |
There was a problem hiding this comment.
Bug: The script uses Pester's Should assertion, which is a test-only command. This will cause a runtime error because Pester is not available in the production GitHub Actions environment.
Severity: CRITICAL
Suggested Fix
Replace the Pester Should assertions with standard PowerShell conditional checks. For line 139, use if ($OriginalTag -ne '') { throw "..." }. For line 258, use if ($OriginalTag -eq '') { throw "..." } to validate the state of the $OriginalTag variable.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: updater/scripts/update-dependency.ps1#L139
Potential issue: The script `updater/scripts/update-dependency.ps1` uses Pester-specific
assertions (`$OriginalTag | Should -Be ''` on line 139 and `$OriginalTag | Should -Not
-Be ''` on line 258). These commands are only available within a Pester test execution
context and require the Pester module to be loaded. Since the script is executed
directly in a GitHub Actions workflow without loading Pester, PowerShell will not
recognize the `Should` command. This will cause a fatal runtime error, making the action
fail immediately upon execution in both its discovery and explicit modes.
Did we get this right? 👍 / 👎 to inform future reviews.
Summary
Fixes a bug where the
OriginalTagparameter was not passed to the post-update script on the second run ofupdate-dependency.ps1in the updater action.Problem
When the updater creates a new PR and runs the update-dependency script a second time (at the "After new PR: redo the update" step), it only passed the
-Tagparameter but not the-OriginalTagparameter. This violated the script's validation requirement that whenTagis set,OriginalTagmust also be provided (see update-dependency.ps1:258).Solution
-OriginalTag '${{ steps.target.outputs.originalTag }}'on the second runTagandOriginalTagare explicitly providedTagis provided withoutOriginalTagTest Plan
🤖 Generated with Claude Code